{extend name='public/base' /}
{block name="css"}

{/block}
{block name="content"}

<div class="ibox xiaoshi">
    <div class="ibox-content">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form class="form-inline" id="form">
                    <div class="select-list">
                        <ul>
                            {:li_input('名称','name')}

                            {:li_select(['1'=>'不显示','2'=>'显示'],'状态','is_show')}

                            {:li_time('时间范围')}

                            {:li_search()}

                        </ul>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-content">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success  btn-rounded {:node('article.ArticleCate/add')}" onclick="$.form.add()">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                    <a class="btn btn-primary btn-rounded single {:node('article.ArticleCate/edit')}" onclick="$.form.edit()">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger btn-rounded multiple {:node('article.ArticleCate/del')}" onclick="$.form.removeAll()">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                </div>
                <div class="table-striped">
                    <table id="bootstrap-table" ></table>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"} <!--js处理区-->

<script>
    $(function() {
        var options = {
            url: "{:url('index')}",
            deleteUrl:  "{:url('del')}?id={id}", //删除链接
            exportUrl:  "{:url('export')}",  //导出
            updateUrl: "{:url('edit')}?id={id}", //编辑
            addUrl:    "{:url('add')}", //添加
            detailUrl:  "/detailUrl",    //详细
            sortName: "id",
            sortOrder: "desc",
            modalName: "栏目管理",
            onDblClickRow:onDblClickRow, //双击行编辑
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID'
                },
                {
                    field: 'title_show',
                    title: '栏目名称'
                },
                {
                    field: 'url',
                    title: '栏目地址',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,30,'open');
                    }
                },
                {
                    field: 'models.name',
                    title: '模型名'
                },
                {
                    field: 'sort',
                    title: '排序'
                },
                {
                    field: 'description',
                    title: '栏目描述',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,50,'open');
                    }
                },
                {
                    field: 'is_show',
                    title: '是否显示',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (value == 0) {
                            return '<span class="badge badge-danger">不显示</span>';
                        } else{
                            return '<span class="badge badge-info">显示</span>';
                        }
                    }
                },
                {
                    field: 'create_time',
                    title: '添加时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return edit_del(row);
                    }

                }]
        };
        $.table.init(options);
    });

    function edit_del(row) {
        var actions = [];
        actions.push('<a class="btn btn-xs btn-success  {:node(\'article.ArticleCate/edit\')}" data-original-title="编辑" data-toggle="tooltip" onclick="$.form.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i></a>');
        actions.push('<a class="btn btn-danger btn-xs {:node(\'article.ArticleCate/del\')}" data-original-title="删除" data-toggle="tooltip" onclick="$.form.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i></a>');
        return actions;
    }



    //双击行编辑
    function onDblClickRow(row) {
        $.form.edit(row.id);
    }


</script>

{/block}
